<%@ page import="Model.*"%>
<%@ page import="Model.Wall.*"%>
<%@ page import="Model.DateProfile.*"%>
<%@ page import="Model.OtherUser.*" %>
<script type="text/javascript">
function flirt_sent()
{
alert("flirt sent!");
}
</script>

<%-- <script type="text/javascript">
var timer = setInterval(function() { $('#header').load('header.jsp'); }, 8000);
</script>

<div class ="header">

</div> --%>


<%@include file="header.jsp"%>

<hr class="noscreen" />
<%
	int profileID = -1;
	if(session.getAttribute("loggedIn") != Boolean.TRUE) {
	%>
<meta HTTP-EQUIV="REFRESH" content="0; url=login.jsp">
<%} else {
	
	if (request.getParameter("id")!=null)
		profileID = Integer.parseInt(request.getParameter("id")); 
	 User user = new User(profileID); 
	 if (user.getName() == null){
		 user = new User(userID);
		 profileID = userID;
	 }
	 PersonalInfo info = user.getPersonalInfo();
	 
	 session.setAttribute("toID", profileID);
	 
	 boolean myPage = profileID==userID;
	 if(Blocked.isBlocked(profileID, userID)){
	 %>
	<meta HTTP-EQUIV="REFRESH" content="0; url=profile.jsp">
	<%}else{ %>
	 
	
    <h1 id="title"><%=user.getName()%></h1>

<!-- Three columns -->
<div class="content box">

	<div class="content-in box">
		<h2>&nbsp;</h2>

		<div class="col50"
			style="width: 410px; font-size: 80%; text-align: center;">
			<img src="<%="userprofiles/"+profileID+".jpg" %>" width="410"
				height="275" style="padding-bottom: 0.5em;" />
			<%if (myPage){ %>
			<a href="upload.jsp">change picture</a>
			</caption>
			<%} %>
		</div>
		<!-- /col50 -->

		<div class="col50 f-right">
			<table cellpadding=5>
				<tr>
					<td class=profileInfoHeader>Name:</td>
					<td><%=user.getName()%></td>
					<%if (myPage){ %>
					<td><a href="./profileedit.jsp"><img
							src="images/edit-button.png" width="20" height="20" border="0"
							alt=""></a></td>
					<%} %>
				</tr>
				<tr>
					<td class=profileInfoHeader>Sex:</td>
					<td><%=(info.getGender()==1)?"Male":"Female"%></td>
				</tr>
				<tr>
				<tr>
					<td class=profileInfoHeader>Age</td>
					<td><%=info.getAge() %></td>
				</tr>
				<tr>
					<td class=profileInfoHeader>Height:</td>
					<td><%=info.getHeight() %>cm</td>
				</tr>
				<tr>
					<td class=profileInfoHeader>Weight:</td>
					<td><%=info.getWeight() %>lbs</td>
				</tr>
				<tr>
					<td class=profileInfoHeader>Ethnicity:</td>
					<td><%=info.getEthnicity() %></td>
				</tr>
				<tr>
					<td class=profileInfoHeader>Interests:</td>
					<td><%=info.getInterests() %></td>
				</tr>
				<!--<tr>
            <td class=profileInfoHeader>More:</td>
            <td>I love turtles</td>
          </tr>-->

          <%if(!myPage){ %>
          <tr>
            <td>
            	<form name="input" action="createMessage.jsp" method="get">
				<input type="hidden" id="toUser" name="toUser" value=<%=profileID%> />
				<input class="input-submit-small" type="submit" value="Message" />
				</form> 
			</td>
            <td> 
            <form action="/UBCDatingServer/manageother" method="post">
            <input type="hidden" name="userID" value="<%=userID%>" />
            <input type="hidden" name="profileID" value="<%=profileID%>" />
            <% if(!Blocked.isBlocked(userID, profileID)){ %>
            	<%if(!Friends.isFriend(userID, profileID)){ %>
            		<input type="submit" name="button" value="Friend me" class="input-submit" />
            	<%} else { %>
            		<input type="submit" name="button" value="Unfriend me" class="input-submit" />
            	<%} %>
            	<input type="submit" name="button" value="Block me" class="input-submit" />
            <%} else { %>
            <input type="submit" name="button" value="Unblock me" class="input-submit" />
            <%} %>
			<input type="submit" name="button" value="Flirt!" class="input-submit" onclick="flirt_sent()" />
            </form>
          </tr>
          <%} %>
  
        </table></div> 
		<div class="fix"></div>

		<div class="friendsCol">
			<h2>
				<a href="friends.jsp?id=<%=profileID%>">Friends</a>
			</h2>
		</div>
		<%@ include file="Wall.jsp"%>
		<%} %>
	<%} %>
<%@ include file="footer.jsp"%>